package com.example.service.impl;

import com.example.mapper.basisEditMapp;
import com.example.pojo.assProductionPojo;
import com.example.service.basisEditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * ClassName:basisEditImpl
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/10/16 19:30
 * @Version 1.0
 */
@Service
public class basisEditImpl  implements basisEditService {
    //用在装配生产数量上
    @Autowired
    private basisEditMapp basisEditMapp;
    //插入一条新的装配产量信息
    public void basisEditAssProductionInsertOne(assProductionPojo assProductionPojo){
        //设置时间
        assProductionPojo.setEstablishTime(LocalDateTime.now());
        assProductionPojo.setUpdateTime(LocalDateTime.now());
        basisEditMapp.basisEditAssProductionInsertOne(assProductionPojo);
    }
    //查询有多少条生产数据
    public Integer basisQueryAllNumAssProduction(){
        Integer num=basisEditMapp.basisQueryAllNumAssProduction();
        return  num;
    }
    //分页查询出生产数据
    public List<assProductionPojo> paginationQueryAssProduction(Map<String, Object> map){
        Integer pageItems=(Integer) map.get("pageItems");
        Integer pageNum=(Integer) map.get("pageNum");
        //计算开始页
        int pageStart=(pageNum-1)*pageItems;
        System.out.println(pageStart);
        System.out.println(pageItems);
        List<assProductionPojo>  assProduction=basisEditMapp.paginationQueryAssProduction(pageStart,pageItems);
        return assProduction;
    }
    //修改一条装配产量数据
    public void basisEditEditAssProduction(assProductionPojo assProductionPojo){
        //设置修改时间
        assProductionPojo.setUpdateTime(LocalDateTime.now());
        basisEditMapp.basisEditEditAssProduction(assProductionPojo);
    }
    //根据两个字段，查询出数据，就是一行
    public assProductionPojo towFieldQueryAssProduction(Map<String, Object> map){
        String oneFieldName=(String) map.get("oneFieldName");
        String oneFieldVal=(String) map.get("oneFieldVal");
        String towFieldName=(String) map.get("towFieldName");
        String towFieldVal=(String) map.get("towFieldVal") ;
        assProductionPojo assProductionPojo=basisEditMapp.towFieldQueryAssProduction(oneFieldName,oneFieldVal,towFieldName,towFieldVal);
        return assProductionPojo;
    }

}
